import { DeleteDto, IndexDto, ShowDto } from '@libs/common/dto';
import { ApiProperty, PartialType } from '@nestjs/swagger';
import { IsNotEmpty } from 'class-validator';

import {
  OvertimeApply,
  OvertimeApplyStatus,
} from '../entities/overtime-apply.entity';

export class IndexOvertimeApplyDto extends IndexDto<OvertimeApply> {}

export class ShowOvertimeApplyDto extends ShowDto {}

export class DeleteOvertimeApplyDto extends DeleteDto {}

export class CreateOvertimeApplyDto {
  @ApiProperty({ description: '钉钉ID' })
  @IsNotEmpty({ message: '钉钉ID不能为空' })
  dingId: string;

  @ApiProperty({ description: '卡片实例Id' })
  @IsNotEmpty({ message: '卡片实例Id不能为空' })
  outTrackId: string;

  @ApiProperty({ description: '可用时长/单位分钟' })
  @IsNotEmpty({ message: '申请时长不能为空' })
  time: number;

  @ApiProperty({ description: '开始时间' })
  @IsNotEmpty({ message: '开始时间不能为空' })
  startDate: string;

  @ApiProperty({ description: '结束时间' })
  @IsNotEmpty({ message: '结束时间不能为空' })
  endDate: string;

  @ApiProperty({ description: '加班原因' })
  @IsNotEmpty({ message: '加班原因不能为空' })
  description: string;

  @ApiProperty({ description: '状态' })
  @IsNotEmpty({ message: '状态不能为空' })
  status: OvertimeApplyStatus;
}

export class UpdateOvertimeApplyDto extends PartialType(
  CreateOvertimeApplyDto,
) {
  @ApiProperty()
  @IsNotEmpty({ message: 'id 不能为空' })
  id: string;

  // @ApiProperty({ description: '审批人' })
  // @IsNotEmpty({ message: '审批人不能为空' })
  // approver: string;

  @ApiProperty({ description: '钉钉审批实例ID' })
  instanceId?: string;

  @ApiProperty({ description: '审批时间' })
  @IsNotEmpty({ message: '审批时间不能为空' })
  approveTime: string;
}

export class FindOvertimeApplyDto extends PartialType(UpdateOvertimeApplyDto) {}

export class SwitchOvertimeApplyDto {
  @ApiProperty()
  @IsNotEmpty({ message: 'id 不能为空' })
  id: string;

  @ApiProperty({ description: '状态' })
  @IsNotEmpty({ message: '状态不能为空' })
  status: OvertimeApplyStatus;
}

export class ImportOvertimeApplyDto {}

export class ExportOvertimeApplyDto {}
export class CountOvertimeApplyDto {
  dingId?: string;
  userId?: string;
  status?: OvertimeApplyStatus;
}
export class UpdateStatusOvertimeApplyDto {
  @ApiProperty({ description: '状态' })
  @IsNotEmpty({ message: '状态不能为空' })
  status: OvertimeApplyStatus;

  @ApiProperty({ description: '卡片实例Id' })
  @IsNotEmpty({ message: '卡片实例Id不能为空' })
  outTrackId: string;
}
